import request from '@/api/http.js'

// 获取工单列表数据详情 
export const WorkOrderSearchListDetail = (id) =>{
    return request.get('api/ProductionWorkOrder/getDetailPageData?id='+id)
}

// 获取工单列表数据
export const WorkOrderSearchList = (params) =>{
    console.log('工单列表发送参数:', params)
    const query = new URLSearchParams(params).toString();
    return request.get(`api/ProductionWorkOrder/getPageDate?${query}`)
}


//获取存货数据
export const getInventory = (params) => {
  return request.post('api/Inventory/getPageData', params)
}

//获取工序数据
export const getProcess = (params) => {
    return request.post('api/Process/getPageData', params)
}

// 获取工单编号
export const getProcessCode = () => {
    return request.get('api/ProductionWorkOrder/GetProductionWorkOrder')
}

// 新增工单
export const addProcess = (params) => {
    console.log('addProcess发送参数:', params)
    return request.post('api/ProductionWorkOrder/AddProductionWorkOrder',params)
}

// 更改工单状态
export const changeWorkStatus = (params) => {
    console.log('changeWorkStatus发送参数:', params)
    return request.post('api/ProductionWorkOrder/ChangeProductionWorkOrderStatus',params)
}

// 获取任务列表
export const getWorkorderList = (params) => {
    const query = new URLSearchParams(params).toString();
    console.log('getWorkorderList发送参数:', params)
    return request.get(`api/WorkOrderListTask/getPageDate?${query}`)
}

// 获取员工数据
export const getEmployees = () => {
  return request.post('api/Employees/getPageData', {
    page: 1,
    rows: 10000,
    sort: 'CreateDate',
    order: 'desc',
    wheres: JSON.stringify([])
  })
}
// 获取不良品数据
export const getDefectItem = () => {
    return request.get('api/DefectItem/getPageData', {
      page: 1,
      rows: 10000,
      sort: 'CreateDate',
      order: 'desc',
      defectItemCode: ''
    })
  }

  //编辑任务
  export const updateWorkOrderList = (params) => {
    return request.post('api/WorkOrderListTask/update', params)
}

// 删除任务${id}
export const deleteWorkOrderList = (id) => {
  console.log('删除传递id:', id)
  return request.post(`api/WorkOrderListTask/Delete/${id}`)
}